package com.sh.suhe.utildemos.deleteapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.blankj.utilcode.util.AppUtils;
import com.sh.suhe.utildemos.R;
import com.sh.suhe.utildemos.utils.ToastUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DeleteAppActivity extends AppCompatActivity {

    @BindView(R.id.app_name)
    EditText editText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_delete_app);
        ButterKnife.bind(this);

    }
    @OnClick({R.id.app_delete})
    public void click(View view) {
        String name = editText.getText().toString();
        if (TextUtils.isEmpty(name)) {
            ToastUtils.showToast("请输入包名！");
            return;
        }
        delete(name);
    }
    private void delete(String packageName) {
//        AppUtils.uninstallApp(packageName);
        ToastUtils.showToast("开始卸载！");
        Log.e("DeleteAppActivity", "开始卸载");
        AppUtils.uninstallApp(packageName);
//        Uri uri = Uri.fromParts("package", packageName, null);
//
//        Intent intent = new Intent(Intent.ACTION_DELETE, uri);
//
//        startActivity(intent);
    }
}